package com.qk.mapper;

import com.qk.dto.ActivityDto;
import com.qk.entity.Activity;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ActivityMapper {
    //查询列表
    List<Activity> selectList(ActivityDto activityDto);
    //根据id删除
    @Delete("delete from activity where id= #{id}")
    void deleteById(Integer id);
    //添加
    @Insert("insert into activity (channel,name,start_time,end_time,description,type,discount,voucher,create_time,update_time)" +
            " values(#{channel},#{name},#{startTime},#{endTime},#{description},#{type},#{discount},#{voucher},#{createTime},#{updateTime})" )
    void add(Activity activity);
    //根据id查询
    @Select("select id,channel,name,start_time,end_time,description,type,discount,voucher,create_time,update_time from activity where id= #{id}")
    Activity selectByID(Integer id);
    //修改
    void upDate(Activity activity);
    //根据类型查询
    @Select("select id,channel,name,start_time,end_time,description,type,discount,voucher,create_time,update_time from activity where type= #{type}")
    List<Activity> typeList(Integer type);
}
